<template>
    <div>
        <sticky-top>
            <div class="title">
              <span>系统设置</span>
              <el-divider></el-divider>
            </div>
        </sticky-top>
       
        <div class="container">
            <div class="wrap">
              <el-row>
                <el-col :lg="16" :md="20" :sm="24" :xs="24">
                  <el-form :model="form" status-icon ref="form" label-width="150px" @submit.native.prevent>
                    <el-form-item label="小程序提交审核开关" prop="audit">
                        <el-switch
                        v-model="audit"
                        active-color="#00C292"
                        inactive-color="#E46A76"
                        @change="change">
                      </el-switch>                    
                    </el-form-item>
                    <!-- <el-form-item class="submit">
                      <el-button
                        v-permission="{ permission: ['添加文档自来', '修改文档资料'], type: 'disabled' }"
                        type="primary"
                        @click="submitForm('form')"
                        >保 存</el-button
                      >
                      <el-button @click="resetForm('form')">重 置</el-button>
                    </el-form-item> -->
                  </el-form>
                </el-col>
              </el-row>
            </div>
        </div>
    </div>
    
</template>
<script>

    import SettingModel from '@/model/setting'
    
    export default {
        data() {
            return {
                form: {
                    audit: true
                },
                audit: true
            }
        },
        async mounted() {
            this.getAudit()
            
        },
        methods: {
            async getAudit() {
                const res = await SettingModel.getAudit()
                this.audit = res
            } ,
            async change(val) {
                const res = await SettingModel.updateAudit()
                console.log(res)
                if (res.code < window.MAX_SUCCESS_CODE) {
                    this.$message.success(`${res.message}`)
                    this.getAudit()
                }
            }
        },
    }
</script>
<style lang="scss" scoped>
    @import '@/assets/style/create-edit';
</style>